﻿<!--#include file="utf-8.asp"-->

<%
response.buffer=true '启用缓冲处理
dim conn 
dim connstr
'on error resume next
connstr="driver={sql server};Server=127.0.0.1;Database=shundeidea;uid=sdidea;Password=123456;"
'connstr="driver={sql server};Server=s701.now-cn.net;Database=dbshundeideacom;uid=shundeideacom;Password=njm2nj;"


set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
If Err Then
        err.Clear
        Set Conn = Nothing
        Response.Write "数据库连接出错，请检查数据库连接文件中的数据库参数设置。"
        Response.End
    End If 
sub Chkhttp()
server_vv=len(Request.ServerVariables("SERVER_NAME"))
server_v1=left(Cstr(Request.ServerVariables("HTTP_REFERER")),server_vv)
server_v2=left(Cstr("http://"&Request.ServerVariables("SERVER_NAME")),server_vv)
if server_v1<>server_v2 or server_v1="" or server_v1="" then
response.Charset="utf-8"
response.write("<script>alert('错误：禁止从站点外部提交数据!.')</script>")
response.end
end if
end sub
%>



<!--#include file="seeion.asp"-->
<!--#include file="page.asp"-->
<%
p_type=request("p_type")
if p_type = "Passed" then
	p_id=request("id")
	p_model =request("model")
	set rs=server.createobject("adodb.recordset") 
	exec="select * from [user] where ID="&p_id&"" 
	rs.open exec,conn,2,3
	if not rs.eof then
		if p_model=1 then
			rs("IsPassed") = true
		else
			rs("IsPassed") = false
		end if
	end if 
	rs.update
	rs.close
	set rs=nothing
	response.write "<script>window.location.href='admin_user.asp'</script>"
	response.end
end if

if p_type = "updatedata" then
	p_id=request("id")
	set rs=server.createobject("adodb.recordset") 
	exec="select * from [user] where ID="&p_id&"" 
	rs.open exec,conn,2,3
	rs("user_name") = Trim(request.form("user_name"))
	rs("user_pass") = Trim(request.form("user_pass"))
	rs("Gender") = Trim(request.form("user_Gender"))
	rs("IsPassed") = Trim(request.form("user_IsPassed"))
	rs("IsVIP") = Trim(request.form("user_IsVIP"))
	rs("email") = Trim(request.form("user_email"))
	rs("DateTime") = Trim(request.form("user_DateTime"))
	rs("tel")=Trim(request.form("tel"))
	rs("address")=Trim(request.form("address"))
	rs("qq")=Trim(request.form("qq"))
	rs.update
	rs.close
	set rs=nothing
	response.write "<script>alert('修改成功!')</script>"
	response.write "<script>window.location.href='admin_user.asp'</script>"
	response.end
end if

if p_type = "delete" then
	p_id=request("id")
	set rs=server.createobject("adodb.recordset") 
	exec="select * from [user] where ID="&p_id&"" 
	rs.open exec,conn,2,3
	rs.delete
	rs.close
	set rs=nothing
	response.write "<script>alert('删除成功!')</script>"
	response.write "<script>window.location.href='admin_user.asp'</script>"
	response.end
end if
%>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>列表管理</title>
<link href="images/style.css" type="text/css" rel="stylesheet" />
<style type="text/css">
<!--

-->
</style>
</head>
<body>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
  <tr>
    <td bgcolor="#FFFFFF" class="head"><strong>
<%
dim new_user,vip_user
set rs=server.createobject("adodb.recordset") 
exec="select * from [User]" 
rs.open exec,conn,1,1
new_user=0:vip_user=0
do while not rs.eof
if rs("IsPassed") =false then
	new_user=new_user+1
end if 
rs.movenext
loop
rs.close
set rs=nothing
response.write "新注册会员：" & (new_user) & " 人　"
%></strong></td>
  </tr>
</table>
<p>
  <% if request("p_type") <> "update" then%>
</p>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="cedced">
  <tr bgcolor="e9f1fa">
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-family : sans-serif;">
      <tr height="25">
        <td width="70" align="center">ID</td>
        <td width="12%">用户名</td>
        <td width="12%">公司名称</td>
        <td width="12%">联系电话</td>
        <td width="12%">邮箱地址</td>
        <td width="12%">积分</td>
        <td width="12%">状态</td>
        <td width="60" align="center">审核</td>
        <td width="60" align="center">修改</td>
        <td width="60" align="center"><a href="javascript:if(confirm('确定要删除该条记录吗?')){window.location.href='#';}else{}">删除</a></td>
      </tr>
    </table></td>
  </tr>
</table>
  <%	
set rs=server.createobject("adodb.recordset") 
exec="select * from [user] order by datetime desc" 
rs.open exec,conn,1,1 
if rs.eof then
response.Write "&nbsp;暂无数据！"
response.end
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount 
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif  page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if	
%>
  <%For i=1 To x%>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="cedced" style="font-family:sans-serif;margin:5px 0;">
<tr height="25">
<td width="70" align="center" bgcolor="#FFFFFF"><%=rs("id")%></td>
<td width="12%" bgcolor="#FFFFFF"><%=rs("user_name")%></td>
<td width="12%" bgcolor="#FFFFFF"><%=rs("CompanyName")%></td>
<td width="12%" bgcolor="#FFFFFF"><%=rs("Phone")%></td>
<td width="12%" bgcolor="#FFFFFF"><%=rs("Email")%></td>
<td width="12%" bgcolor="#FFFFFF"><%=rs("Jifen")%></td>
<td width="12%" bgcolor="#FFFFFF"><%=rs("Status")%></td>
<td width="60" align="center" bgcolor="#FFFFFF">
<%
if rs("IsPassed") =true then
response.write "<a href='admin_user.asp?p_type=Passed&id="&rs("id")&"&model=0'>取消审核</a>"
else
response.write "<a href='admin_user.asp?p_type=Passed&id="&rs("id")&"&model=1'>审核</a>"
end if
%></td>
<td width="60" align="center" bgcolor="#FFFFFF"><a href="admin_user.asp?p_type=update&id=<%=rs("id")%>">修改</a></td>
<td width="60" align="center" bgcolor="#FFFFFF"><a href="javascript:if(confirm('确定要删除该条记录吗?')){window.location.href='admin_user.asp?p_type=delete&id=<%=rs("id")%>';}else{}">删除</a></td>
</tr>
</table>
<%rs.movenext
next
%>
<%
end if
%></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><%'以下显示分页
call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
rs.close
set rs=nothing
%></td>
</tr>
</table>
<%else%>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30" bgcolor="#ffffff">
<form name="form1" method="post" action="admin_user.asp?p_type=updatedata&id=<%=request("id")%>">
      <%	
set rs=server.createobject("adodb.recordset") 
exec="select * from [user] where id="&request("id")&"" 
rs.open exec,conn,1,1 
if not rs.eof then
%>
      <table width="488" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="cedced">

        <tr>
          <td width="99" height="25" bgcolor="#FFFFFF">　ID</td>
          <td width="386" height="25" bgcolor="#FFFFFF">　 <%=rs("id")%>
            <label></label></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　用户名</td>
          <td height="25" bgcolor="#FFFFFF">
            　
              <input type="text" name="user_name" id="user_name" value="<%=rs("user_name")%>"></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　密码</td>
          <td height="25" bgcolor="#FFFFFF">
            　
              <input type="text" name="user_pass" id="user_pass" value="<%=rs("user_pass")%>"></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　性别</td>
          <td height="25" bgcolor="#FFFFFF" >　
            <label>
            <select name="user_Gender" id="user_Gender" style="width:100px;">
              <option value="男" <%if rs("Gender")="男" then : response.write "selected=selected" %> >男</option>
              <option value="女" <%if rs("Gender")="女" then : response.write "selected=selected" %> >女</option>
            </select>
            </label></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　审核</td>
          <td height="25" bgcolor="#FFFFFF">　
            <select name="user_ispassed" id="user_ispassed" style="width:100px;">
              <option value="true" <%if rs("IsPassed")="true" then : response.write "selected=selected" %> >审核通过</option>
              <option value="false" <%if rs("IsPassed")="false" then : response.write "selected=selected" %> >取消审核</option>
            </select></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　是否VIP</td>
          <td height="25" bgcolor="#FFFFFF">　
            
            <select name="user_isvip" id="user_isvip" style="width:100px;">
              <option value="true" <%if rs("IsVIP")="true" then : response.write "selected=selected" %> >升级为VIP</option>
              <option value="false" <%if rs("IsVIP")="false" then : response.write "selected=selected" %> >取消VIP</option>
            </select></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　电子邮箱 </td>
          <td height="25" bgcolor="#FFFFFF">　
<input type="text" name="user_email" id="user_email" value="<%=rs("email")%>"></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　联系地址</td>
          <td height="25" bgcolor="#FFFFFF">　
            <input type="text" name="address" id="address" value="<%=rs("address")%>"></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　联系电话</td>
          <td height="25" bgcolor="#FFFFFF">　
            <input type="text" name="tel" id="tel" value="<%=rs("tel")%>"></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF">　QQ</td>
          <td height="25" bgcolor="#FFFFFF">　
            <input type="text" name="qq" id="qq" value="<%=rs("qq")%>"></td>
        </tr>
        <tr>
          <td height="25" bgcolor="#FFFFFF"> 　注册日期</td>
          <td height="25" bgcolor="#FFFFFF">　
            <input type="text" name="user_DateTime" id="user_DateTime" value="<%=rs("DateTime")%>"></td>
        </tr>

        <tr>
          <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
          <td height="25" bgcolor="#FFFFFF">&nbsp;</td>
        </tr>
        <tr>
          <td height="25" colspan="2" align="center" bgcolor="#FFFFFF"><label>
            <input type="submit" name="button" id="button" value="提　交">
           　 
           <input type="button" name="button2" id="button2" value="返　回" onClick="onClick=history.go(-1)">
          </label></td>
          </tr>
      </table>
        <%
end if
rs.close
set rs =nothing
%>
    </form>
    </td>
  </tr>
</table>

<%end if%>



</body>
</html>
